/*
Resource cache for images et cetera.
Be sure not to exceed the local storage limitations.
Requires widget.preferences to be available to work.

NOTE: For now only fetches resources, cache not supported.
*/

/* Downloads the file and returns it as an ANSI string */
function rc_fetch(url) {
	var req = new XMLHttpRequest();
	try {
		req.open("GET", url, false);
		req.responseType="arraybuffer";
		req.send();
	} catch (e) {
		opera.postError("Query error: "+e);
		return null;
	}

	var d = new Uint8Array(req.response);
	var s="";
	for (var i = 0, len = d.length; i < len; ++i)
		s += String.fromCharCode(d[i]);

	return s;
}

/*
Retrieves the fresh version of the resource and stores it in cache.
If the network is down, looks for the cached version.
	url: the resource to be retrieved
	id: the cache-id of this resource. 
	offline:
		on enter:
			set to force offline mode (if it's determined we're offline)
		on exit:
			set if it was determined we're offline
			left clear if the resource was just not found
*/
function rc_get(url, id, offline) {
}

/*
Drops a resource from cache.
Use when it's clear that the resource is no longer needed
(it's missing from the latest design).
*/
function rc_drop(id) {
}

/*
Drops everything from cache.
Use when the design changes.
*/
function rc_clear() {
}